/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.ihmproject.treewindow;

import java.awt.Image;
import java.util.Vector;
import org.openide.nodes.AbstractNode;
import org.ihmproject.modele.NoeudCTT;
import org.openide.ErrorManager;
import org.openide.nodes.PropertySupport;
import org.openide.nodes.Sheet;
import org.openide.util.Utilities;
import org.openide.util.lookup.Lookups;
/**
 *
 * @author sebastien
 */
public class NodeViewCTTE extends AbstractNode{

    public NodeViewCTTE(NoeudCTT obj) {
        super (new MyChildren(), Lookups.singleton(obj));
        setDisplayName (obj.getDescription());
    }


    public NodeViewCTTE() {
        super (new MyChildren());
        setDisplayName ("Root");
    }

    @Override
    public Image getIcon (int type) {
        return Utilities.loadImage ("org/myorg/myeditor/icon.png");
    }

    protected Sheet createSheet() {

    Sheet sheet = Sheet.createDefault();
    Sheet.Set set = Sheet.createPropertiesSet();
    NoeudCTT obj = getLookup().lookup(NoeudCTT.class);

    try {

        Property descriptionProp = new PropertySupport.Reflection(obj, String.class, "getDescription", null);
        Property typeProp = new PropertySupport.Reflection(obj, Integer.class, "getType", null);
        Property decorationProp = new PropertySupport.Reflection(obj, Vector.class, "getDecoration", null);
        Property preconditionProp = new PropertySupport.Reflection(obj, Vector.class, "getPrecondition", null);
        Property operateurProp = new PropertySupport.Reflection(obj, String.class, "getOperateur", null);


        descriptionProp.setName("description");
        descriptionProp.setName("type");
        descriptionProp.setName("decoration");
        descriptionProp.setName("precondition");
        descriptionProp.setName("operateur");

        set.put(descriptionProp);
        set.put(typeProp);
        set.put(decorationProp);
        set.put(preconditionProp);
        set.put(operateurProp);

         } catch (NoSuchMethodException ex) {
            ErrorManager.getDefault();
        }

        sheet.put(set);
    return sheet;

}


}
